package com.yale.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * Created by yale on 2017/10/20.
 */
public class MyIntercepter extends AbstractInterceptor{

    /**
     * @param invocation
     * @return
     * @throws Exception
     * result: 拦截器开始-->执行Action-->3-->拦截器结束
     */
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        System.out.println("拦截器开始");
        long start = System.currentTimeMillis();
//      System.out.println(start);
        String result = invocation.invoke();//执行下一个拦截器或action
        long end = System.currentTimeMillis();
//      System.out.println(end);
        System.out.println(end-start);
        System.out.println("拦截器结束");
        return result;
    }
}
